<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>stapes例子11</title>
    <script type="text/javascript" src="../lib/stapes-0.8.1/stapes.js"></script>
    <script type="text/javascript" src="../lib/jquery-easyui-1.4.2/jquery.min.js"></script>
</head>
<body>
<h1>你好!!!</h1>

<div id="app">11111</div>


<script type="text/javascript">
    var Module = Stapes.subclass();

    var module = new Module();

    module.on('ready', function () {
        console.log('your module is ready!');
    });

    module.on({
        "talk": function () {
            console.log('your module is talking!');
        },

        "walk": function () {
            console.log('your module is walking!');
        },

        "eat": function (food) {
            console.log('your module is eating ' + (this.get('food') || 'nothing'));
        }
    });

    var feedme = new Module();

    // Set the scope for the event handler to 'module'
    feedme.on({
        "feed": function (food) {
            this.set('food', food);
        }
    }, module);

    module.emit('eat');
    // "your module is eating nothing"

    feedme.emit('feed', 'cookies');

    module.emit('eat');
    // "your module is eating cookies"

    module.get('food');
    // "cookies"

    feedme.get('food');
    // null

</script>


</body>
</html>